/* Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.flowable.app.repository.editor;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.flowable.app.domain.editor.Flow;
import org.flowable.app.domain.editor.Model;
import org.flowable.app.repository.UuidIdGenerator;
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class CusFlowRepositoryImpl implements CusFlowRepository {

    private static final String NAMESPACE = "org.flowable.app.domain.editor.Flow.";

    @Autowired
    protected SqlSessionTemplate sqlSessionTemplate;

    @Autowired
    protected UuidIdGenerator idGenerator;



    @Override
    public void insertCusFlow(Flow model) {
        sqlSessionTemplate.insert(NAMESPACE + "insertCusFlow", model);
    }

    @Override
    public void updateFlowState(Flow model) {
        sqlSessionTemplate.update(NAMESPACE + "updateFlowState", model);
    }

    @Override
    public void deleteFlowByProcessInstId(String processInstid) {
        sqlSessionTemplate.delete(NAMESPACE + "deleteFlowByProcessInstId", processInstid);
    }

    @Override
    public List<Flow> selectFlowByDeploymentKeyAndState(Flow model) {
        return sqlSessionTemplate.selectList(NAMESPACE + "selectFlowByDeploymentKeyAndState", model);
    }

    @Override
    public List<Flow> selectFlowByProcessInstId(String processInstid) {
        return sqlSessionTemplate.selectList(NAMESPACE + "selectFlowByProcessInstId", processInstid);
    }

    @Override
    public List<Flow> selectAllFlow() {
        return sqlSessionTemplate.selectList(NAMESPACE + "selectAllFlow");
    }
}
